// 按需引入 crypto-js 的 AES 加密相关模块
const CryptoJS = require('crypto-js/aes');
const CryptoJS_enc = require('crypto-js/enc-utf8');
const CryptoJS_mode = require('crypto-js/mode-ecb');
const CryptoJS_pad = require('crypto-js/pad-pkcs7');

// 定义加密的密钥
var key = CryptoJS_enc.parse('51rzmHLuQEQ+WjMAkJ6Zgy2wQ4RsZlVR');

const encryptWithTimestamp = () => {
    // 获取当前时间戳
    var timestamp = new Date().getTime().toString();
    console.log(timestamp);
    // 对数据进行加密
    var encrypted = CryptoJS.encrypt(timestamp, key, {
        mode: CryptoJS_mode.ECB,
        padding: CryptoJS_pad.Pkcs7
    });
    return encrypted.toString();
};

module.exports = {
    encryptWithTimestamp
};
